<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::namespace('Api')->prefix('v1')->group(function (){
    Route::post('login','AuthController@login');

    Route::get('event-list','EventController@event_list');
    Route::get('event/preview/{event_code}','EventController@preview');
    Route::get('event/preview/{event_code}/{event_phone}','EventController@preview_phone');
    Route::get('event/check/{event}/{event_code}','EventController@check_code');

    Route::get('message/{event}','MessageController@show');
    Route::post('message/{event}','MessageController@create');

    Route::post('enroll/{event}','EnrollController@create');
    Route::get('enroll/{email}/{phone}','EnrollController@events');

    Route::middleware('auth:api')->group(function (){
        Route::post('logout','AuthController@logout');

        Route::get('datetime','SystemController@datetime');

        Route::get('event/my','EmployeeController@events');
        Route::get('event/unreplied','EventController@unreplied');
        Route::get('event','EventController@index');
        Route::post('event','EventController@create');
        Route::get('event/{event}','EventController@show');
        Route::delete('event/{event}','EventController@delete');
        Route::patch('event/employees/{event}','EventController@employees');
        Route::patch('event/client/{event}','EventController@client');

        Route::get('employee','EmployeeController@index');
        Route::post('employee','EmployeeController@create');
        Route::get('employee/{user}','EmployeeController@show');
        Route::delete('employee/{user}','EmployeeController@delete');
        Route::post('employee/accept/{event}','EmployeeController@accept');
        Route::post('employee/finish/{event}','EmployeeController@finish');

        Route::get('client','ClientController@index');
        Route::post('client','ClientController@create');
        Route::get('client/{client}','ClientController@show');
        Route::delete('client/{client}','ClientController@delete');
    });
});